'use strict';let _Vr=0;function _Ih(){return _Vr||"undefined"!=typeof _li&&!_Pt(_li)}function _T(b,f,g,l){let m=g.bkgrnd?[0]:_Nd(b);++_Vr;_nw(g.scriptId,m,b,l)(e=>{--_Vr;g.async||f(e)});g.async&&f(b)}
let _nw=_wj(function*(b,f,g,l){let m=yield _Je(b);if(m){b=yield _2g(b,f,g,m,void 0,l,!0);f=!1;l=[];for(let e of b)if(e)if(e===(e|0)&&(e=[e]),_Mg(e))f=!0,l.push(...e.map(n=>_Mg(n)?_Vs(n):_os[n]?n:null).filter(n=>n));else if("object"==typeof e&&"string"==typeof e.break&&1==Object.keys(e).length)return e;if(f)return l}return g}),_2g=_wj(function*(b,f,g,l,m,e,n,r){let a=[];for(let c of f)0<=c&&a.push(_Qd(b,c,g,l,m,e,n,r));return yield Promise.all(a)}),_Ik;
{var _Qd=function(a,c,d,h,p,k,t,u){return new Promise((v,w)=>{_bf(c,{scriptId:a,tabId:c,targetTabs:d,funcCode:p?h+"":`${55>_Ok?"":"async"}()=>{\n${h}\n}`,args:_3y(p),trigInstId:k,frmFlt:u})(q=>{q=q||{};!t&&"error"in q?w(q.error):v(q.result)})})},_bf=(a,c)=>(d=_Qu)=>{+a?c.frmFlt?r(+a,c,d):n(+a,c,d):e(c,d)};window.addEventListener("message",a=>m(a.data,{id:0},c=>a.source.postMessage({result:c,pongId:a.data.pingId},"*")));_Ky.runtime.onMessage.addListener((a,c,d)=>{m(a,c.tab,d);return!0});let b={},f=
a=>{for(var c=1;c in b;++c);b[c]=a;return c};const g=a=>_Ky.runtime.getURL(_gi)+"?file="+encodeURIComponent(a),l=_Ow(-700,a=>_ep()(c=>_gu(c)._ga(a)));let m=function(a,c,d){if(a.pongId)b[a.pongId]&&"dontDel"!=b[a.pongId](a.result)&&delete b[a.pongId];else if(c&&"userAPI"==a.type){++_Vr;let h=()=>_Ik(a,c)((...p)=>{--_Vr;d(...p)});_Ik?h():_oh("/file59.js",h)}else a.imprtSttgs?l(a.imprtSttgs):a.viewSttgs?_Ky.tabs.create({active:!0,url:g(a.viewSttgs)}):a.redirSttgs&&_Ky.tabs.update(c.id,{url:g(a.redirSttgs)})},
e=_Et(function*(a,c){let d=document.getElementById("BGScript");d||(d=_Lo('<iframe id=BGScript src="file7.html">').children[0],yield h=>{d.onload=h;document.body.appendChild(d)});a.pingId=f(c);d.contentWindow.postMessage(a,"*")}),n=_Et(function*(a,c,d){for(let p=0;;++p){var h=yield k=>_Ky.tabs.sendMessage(a,c,{frameId:0},k);_fy("msgToIsolCtx");if(void 0!==h||0<p||c.event)break;try{yield _rk(a,{file:"file47.js"})}catch(k){return d({error:k})}}d(h)}),r=_Et(function*(a,c,d){try{let h=
yield _rk(a,{allFrames:!0,matchAboutBlank:!0,code:"!!window.FN"});h.filter(k=>!k).length&&(h=yield _rk(a,{allFrames:!0,matchAboutBlank:!0,file:"file47.js"}));let p=h.length;h=[];c.frmCBId=f(k=>{if(k){if("error"in k)return d(k);h.push(k.result)}if(--p)return"dontDel";d({result:h})});yield k=>_Ky.tabs.sendMessage(a,c,k);_fy()}catch(h){return d({error:h})}})}let _Je=_wj(function*(b){(b=_er(b,"script").value)&&b.srcFile&&(b=yield _ka(b.srcFile,!0));return b?b.srcCode:""});
var _ka=_wj(function*(b,f){b=yield _9y(b);let g=_7s(b);if(_0j(b)||!_Zk(b)){f=yield _i(b,"text",_Kg(g,"ldTime")||0);if(f.error)return{error:f.error};if(null!=f.content)return _7s(b,{srcCode:f.content,encode:f.charEnc,ldTime:Date.now()})}else if(!g||6E4<Date.now()-g.checkTime){let l=_wj(function*(){let [m,e]=yield _Ya(_n(b,"text",void 0,void 0,{"If-Modified-Since":(new Date(_Kg(g,"ldTime")||0)).toUTCString()}));return 200==e.status?_7s(b,{srcCode:m,ldTime:Date.now(),checkTime:Date.now()}):304==e.status?
_7s(b,g.add({checkTime:Date.now()})):{error:e.status}});if(f&&g)l()();else return yield l()}return g});
_2i.script={saveAllImg:{name:"Example 1: Download all images",help:"",value:{srcCode:"let count = 0 ;\n//for each image in the page\nfor(let image of document.images){\n\t//if the image is bigger than 100x100 pixels\n\tif( image.src && image.width > 100 && image.height > 100 ){\n\t\t//save it to the desktop under a folder named after the page's domain\n\t\tlet filepath = await ACtl.saveURL(image.src, `<desktop>/${location.hostname}/`) ;\n\t\tconsole.log(++count, image.src, ' --\x3e ', filepath) ;\n\t}\n}\nalert(count + ' IMAGES SAVED.') ;"}},captTabPub:{name:"Example 2: Take page screenshot and upload it",
help:"",value:{srcCode:"//Take a shot of the current tab\nlet [[, dataUri]] = await ACtl.captureTab('#currentTab') ;\n//Put the image in the clipboard\nawait ACtl.setClipboard({image: dataUri}) ;\n//Open http://snag.gy in a new tab\nlet [tabId] = await ACtl.openURL('http://snag.gy', {rightOf: '#currentTab'}) ;\n//Wait for the tab to finish loading\nawait ACtl.on('tabLoadEnd', tabId) ;\n//Activate the new tab and focus its window\nawait ACtl.setTabState(tabId, 'active focused') ;\n//Execute AutoControl's [CLIPBRD PASTE] action\nawait ACtl.execAction('#clpbrdPaste') ;"}}};
